package com.scuec.tourismwebsite.service;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.scuec.tourismwebsite.entity.FreeformPostComment;
import com.scuec.tourismwebsite.mapper.FreeformPostCommentMapper;
import com.scuec.tourismwebsite.vo.Fcomment;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
//
import java.util.Collections;
import java.util.List;

@Service
public class FreeformPostCommentServiceImpl implements FreeformPostCommentService{
    @Autowired
    private FreeformPostCommentMapper freeformPostCommentMapper;

    @Override
    public Integer deleteCommentById(Integer comment_id) {
        return freeformPostCommentMapper.deleteCommentById(comment_id);
    }

    @Override
    public Integer insertComment(FreeformPostComment freeformPostComment) {
        return freeformPostCommentMapper.insertComment(freeformPostComment);
    }

    @Override
    public List<Fcomment> findCommentByIdCo(Integer post_id, String comment_content) {
        return freeformPostCommentMapper.findCommentByIdCo(post_id,comment_content);
    }

    @Override
    public List<Fcomment> findCommentrById(Integer post_id) {
        return freeformPostCommentMapper.findCommentById(post_id);
    }


    @Override
    public PageInfo<Fcomment> findFcommentPages(Integer post_id, Integer pageNum, Integer pageSize) {
        PageHelper.startPage(pageNum,pageSize);
        List<Fcomment> lists = freeformPostCommentMapper.findCommentById(post_id);
        PageInfo<Fcomment> pageInfo = new PageInfo<>(lists);
        return pageInfo;
    }

    @Override
    public PageInfo<Fcomment> findFcommentPage(Integer post_id, String comment_content, Integer pageNum, Integer pageSize) {
        PageHelper.startPage(pageNum,pageSize);
        List<Fcomment> lists = freeformPostCommentMapper.findCommentByIdCo(post_id,comment_content);
        PageInfo<Fcomment> pageInfo = new PageInfo<>(lists);
        return pageInfo;
    }
}
